package com.cloudree.gllib.activity;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.cloudree.gllib.BaseActivity;
import com.cloudree.gllib.R;
import com.cloudree.gllib.util.FragmentUtil;

public class TextureActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_base);
        setTitle("Texture");
    }

    @Override
    public void init() {
        mManager = getSupportFragmentManager();
        fragments = FragmentUtil.getTextureFragments();
        mManager.beginTransaction()
                .add(R.id.content_container, fragments.get(0))
                .commit();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_texture, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int selectedIndex = 0;
        switch (item.getItemId()) {
            case R.id.texture_multi:
                selectedIndex = 0;
                break;
            case R.id.texture_common:
                selectedIndex = 1;
                break;

        }
        mManager.beginTransaction()
                .replace(R.id.content_container, fragments.get(selectedIndex))
                .commit();
        index = selectedIndex;
        setTitle(item.getTitle());
        return super.onOptionsItemSelected(item);

    }
}
